@extends('admin.admin')

@section('style')
    <link href="{{ asset('dist/lib/fileinput/css/fileinput.min.css') }}" rel="stylesheet">
@endsection

@section('content')
    @include('vendor.ueditor.assets')
    <div class="main animsition">
        <div class="container-fluid">
            <div class="row">
                <div class="">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title">添加广告</h3>
                        </div>
                        <div class="panel-body">

                            <form class="form-horizontal" role="form" method="POST" action="{{ url('admin/goods/add_post') }}" enctype="multipart/form-data">
                                <input type="hidden" name="_token" value="{{ csrf_token() }}">
                                @include('admin.goods._form')
                                <div class="form-group">
                                    <div class="col-md-7 col-md-offset-3">
                                        <button type="submit" class="btn btn-primary btn-md">
                                            <i class="fa fa-plus-circle"></i>
                                            添加
                                        </button>
                                    </div>
                                </div>

                            </form>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@stop

@section('script')
    <script type="text/javascript" src="{{ asset('dist/lib/fileinput/js/fileinput.min.js') }}"></script>
    <script type="text/javascript" src="{{ asset('dist/lib/fileinput/js/fileinput_locale_zh.js') }}"></script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container');
        ue.ready(function() {
            ue.execCommand('serverparam', '_token', '{{ csrf_token() }}'); // 设置 CSRF token.
        });

        $('.type2_text').show();
        $("input[name='type1']").change(function(){
            var val = $(this).val();
            if(val == 1){
                // 图片类
                $('.type2_pic').attr('disabled',true);
            }else{
                // 内容类
                $('.type2_pic').attr('disabled',false);
            }
        })

        $("input[name='type2']").change(function(){
            var val = $(this).val();
            if(val == 1){
                // 图片类
                $('.type2_text').hide();
                $('.type2_img').show();
            }else{
                // 内容类
                $('.type2_text').show();
                $('.type2_img').hide();
            }
        })


            $("#input-24").fileinput({
                showCaption: false,
                showRemove: true,
                showCancel: true,
                uploadAsync:true,
                dropZoneEnabled:true,
                overwriteInitial: false,
                resizeImage: true,
                maxFileSize: 5070,
                initialCaption: "The Moon and the Earth",
                previewFileType :"image",
                uploadUrl: "{{ url('admin/upload_img') }}",
                previewFileIcon:"",
                maxFileCount: 1,
                minFileCount: 1,
                msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}！",
                dropZoneTitle: "把文件拖拽"
            }).on('filedeleted', function(outData) {
                $('input[name=img]').val('');
            }).on("fileuploaded", function(event, outData) {
                //文件上传成功后返回的数据， 此处我只保存返回文件的id
                var result = outData.response.url;
                // 对应的input 赋值
                $('input[name=img]').val(result).change();
            });



    </script>
@stop